<?php if(!defined('HOST'))die('not access');?>
<style>
.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td{vertical-align:middle;}
th {font-weight:none !important;}
</style>
<script>
(function (window) {
// 将小数点清零
var toInteger = function (value) {
value = Math.round(parseFloat(value));
return value;
};
// 保留一位小数点
var toDecimal = function (value) {
value = Math.round(parseFloat(value) * 10) / 10;
if (value.toString().indexOf(".") < 0) {
value = value.toString() + ".0";
}
return value;
}
// 保留两位小数点
var toFloat = function (value) {
value = Math.round(parseFloat(value) * 100) / 100;
if (value.toString().indexOf(".") < 0) {
value = value.toString() + ".00";
}
return value;
}
// 保留两位小数点，一位小数自动补零
var toZero = function (value) {
value = Math.round(parseFloat(value) * 100) / 100;
var xsd = value.toString().split(".");
//Ext.log(xsd.length);
if (xsd.length == 1) {
value = value.toString() + ".00";
return value;
}
if (xsd.length > 1) {
if (xsd[1].length < 2) {
value = value.toString() + "0";
}
return value;
}
}
window.fomatFloat = {
toInteger: toInteger,
toDecimal: toDecimal,
toFloat: toFloat,
toZero: toZero,
};
})(window);
// 方法，若为null 显示为短横线'-'
function reline(data){
}
// 调整表头与表格对齐的方法
function fun_table_width() {
    var box_h = $('.table-box').height()
    var con_h = $('#veiw_{rand}').height()
    if (con_h > box_h) {$('#table_h').css('width', '99.4%')}
    else {$('#table_h').css('width', '100%')}
}
//每页展示的数据
// var limit = 10;
    //列表展示
    function summaryListsadmin(params = new Object()){
        params['utype'] = 1;
        $.ajax({ url:js.getajaxurl('getProjectInfoList','{mode}','{dir}'), data:params, success: function(obj){
        obj = JSON.parse(obj);
        var data = obj.rows;
        var mergeids = '';
        var projectNum = 0;
        var budgetTotal = 0.00;
        var companyName = "";
        //总计
        var totalPrice = 0.00;
        //序号
        var No = 0;
        var len = data.length - 1;
        //定义表头
        var content = "<table class='table table-bordered table-hover' style='position:relative;table-layout: fixed;word-break:break-all; word-wrap:break-all;'>";
        content += "<thead>";
        // content += "<thead><tr style=''>" +
        //     // "<td>勾选</td>" +
        //     "<td>序号</td>" +
        //     "<td width='60'>单位</td>" +
        //     "<td width='80'>项目名称</td>" +
        //     "<td>批准书文号<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td width='80'>批准书获得时间<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>采购类别</td>" +
        //     "<td width='80'>采购方式</td>" +
        //     "<td>预算金额<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>审减后金额<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>中标金额<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>节约金额(预算节约)<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>节约金额(审减节约)<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>节约率(预算)<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>节约率(审减)<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td width='80'>代理机构<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>报名单位情况<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>公告时间<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>开标时间<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>完标时间<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>中标单位<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>合同是否签订<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>档案整理情况<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>项目进展情况<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>备注<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td width='60'>项目负责人</td>" +
        //     "<td width='60'>操作</td>" +
        //     "</tr></thead>";
        
        //渲染数据到table
        $.each(data, function(i, field){
            if(isempt(field.projecticp)) {
                field.projecticp = '';
            }
            totalPrice += parseFloat(field.budget);
            budgetTotal += parseFloat(field.budget);
            var mergeid = field.mergeids;
            var radioTmp = '';
            var NoTmp = '';
            var companynameTmp = '';
            var nameTmp = '';
            var projecticpTmp = '';
            var proicptimeTmp = '';
            var typeTmp = '';
            var buymodeTmp = '';
            var proxygovTmp = '';
            var startbiddateTmp = '';
            var projecterNameTmp = '';

            if(mergeids != mergeid && !isempt(mergeid)) {
                No++;
                mergeids = mergeid;
                if(field.countmergeids>0){
                    mergeNum = field.countmergeids;
                }else{
                    mergeNum = mergeid.split(",").length;
                }
                
                // radioTmp = "<td rowspan=\""+mergeNum+"\"><input type='radio' name='id_checked' value='"+field.id+"'></td>";
                NoTmp = "<td width='25' rowspan=\""+mergeNum+"\"><div style='min-height: 5rem;'>"+No+"</div></td>";
                companynameTmp = "<td width='50' rowspan=\""+mergeNum+"\"><div style='min-height: 5rem;'>"+field.companyname+"</div></td>";
                nameTmp = "<td width='50' rowspan=\""+mergeNum+"\"><div style='width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;' class=\"input\" data-name=\"name\" id='"+field.id+"'>"+field.name+"</div></td>";
                projecticpTmp = "<td width='50' rowspan=\""+mergeNum+"\" ><div style='width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;' class=\"input\" data-name=\"projecticp\" id='"+field.id+"'>"+field.projecticp+"</div></td>";
                proicptimeTmp = "<td width='50' rowspan=\""+mergeNum+"\"><div style='width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;' class=\"date\" data-name=\"proicptime\" id='"+field.id+"'>"+field.proicptime+"</div></td>";
                typeTmp = "<td width='50' rowspan=\""+mergeNum+"\"><div style='min-height: 5rem;'>"+field.type+"</div></td>";
                buymodeTmp = "<td width='50' rowspan=\""+mergeNum+"\"><div style='min-height: 5rem;'>"+field.buymode+"</div></td>";
                proxygovTmp = '<td width="50" rowspan="'+mergeNum+'"><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="select" data-name="proxygov" id="'+field.id+'">'+field.proxygov+'</div></td>';
                startbiddateTmp = '<td width="50"  rowspan="'+mergeNum+'"><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="date" data-name="startbiddate" id="'+field.id+'">'+field.startbiddate+'</div></td>';
                projecterNameTmp = "<td width='50' rowspan=\""+mergeNum+"\"><div style='min-height: 5rem;'>"+field.projecterName+"</div></td>";
            } else if(isempt(mergeid)){
                // radioTmp = "<th><input type='radio' name='id_checked' value='"+field.id+"'></th>";
                if(isempt(field.no)) {
                    No++;
                    NoTmp = "<td width='25'>"+No+"</td>";
                }else{
                    NoTmp = "<td width='25'>"+No+"</td>";
                }
                companynameTmp = "<td width='50'><div style='min-height: 5rem;'>"+field.companyname+"</div></td>";
                nameTmp = "<td width='50'><div style='width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;' class=\"input\" data-name=\"name\" id='"+field.id+"'>"+field.name+"</div></td>";
                projecticpTmp = "<td width='50'><div style='width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;' class=\"input\" data-name=\"projecticp\" id='"+field.id+"'>"+field.projecticp+"</div></td>";
                proicptimeTmp = "<td width='50'><div style='width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;' class=\"date\" data-name=\"proicptime\" id='"+field.id+"'>"+field.proicptime+"</div></td>";
                typeTmp = "<td width='50'><div style='min-height: 5rem;'>"+field.type+"</div></td>";
                buymodeTmp = "<td width='50'><div style='min-height: 5rem;'>"+field.buymode+"</div></td>";
                proxygovTmp = '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="select" data-name="proxygov" id="'+field.id+'">'+field.proxygov+'</div></td>';
                startbiddateTmp = '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="date" data-name="startbiddate" id="'+field.id+'">'+field.startbiddate+'</div></td>';
                projecterNameTmp = "<td width='50'><div style='min-height: 5rem;'>"+field.projecterName+"</div></td>";
            }
            if(companyName == field.companyname) projectNum += 1;
            if(companyName != field.companyname && projectNum >0) {
                //budgetTotal = budgetTotal-parseInt(field.budget);
                budgetTotal = eval(budgetTotal-parseFloat(field.budget));
                budgetTotal = fomatFloat.toZero(budgetTotal);
                content += "<tr>";
                content += "<th></th>";
                content += "<th colspan='6' align='left'>小计</th>";
                content += "<th colspan='19'>"+budgetTotal+"</th>";
                content += "</tr>";
            }
            if(companyName != field.companyname) {
                companyName = field.companyname;
                budgetTotal = eval(parseFloat(field.budget)-0);
                //budgetTotal = fomatFloat.toZero(budgetTotal);
                projectNum = 1;
            }
            content += "<tr>";
            // content += radioTmp;
            content += NoTmp;
            content += companynameTmp;
            content += nameTmp;
            content += projecticpTmp;
            content += proicptimeTmp;
            content += typeTmp;
            content += buymodeTmp;
            content += '<td width="75" style="font-weight:none !important;" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="input" data-placement="bottom" data-name="budget" id="'+field.id+'">'+field.budget+'</div></td>';
            content += '<td width="75" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="input" data-placement="bottom" data-name="aftercheckmoney" id="'+field.id+'">'+field.aftercheckmoney+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="input" data-placement="bottom" data-name="zbmoney" id="'+field.id+'">'+field.zbmoney+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="input" data-placement="bottom" data-name="savemoney_ys" id="'+field.id+'">'+field.savemoney_ys+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="input" data-placement="bottom" data-name="savemoney_sj" id="'+field.id+'">'+field.savemoney_sj+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="input" data-placement="bottom" data-name="saverate_ys" id="'+field.id+'">'+field.saverate_ys+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="input" data-placement="bottom" data-name="saverate_sj" id="'+field.id+'">'+field.saverate_sj+'</div></td>';
            content += proxygovTmp;
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="textarea" data-placement="bottom" data-name="signupcompany" id="'+field.id+'">'+field.signupcompany+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="date" data-placement="bottom" data-name="proclamationdate" id="'+field.id+'">'+field.proclamationdate+'</div></td>';
            content += startbiddateTmp;
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="date" data-placement="bottom" data-name="wbtime" id="'+field.id+'">'+field.wbtime+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="textarea"  data-placement="bottom" data-name="zbcompany" id="'+field.id+'">'+field.zbcompany+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="select1" data-placement="bottom" data-name="issignagreement" id="'+field.id+'">'+field.issignagreement+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="textarea" data-placement="bottom" data-name="projectfiles" id="'+field.id+'">'+field.projectfiles+'</div></td>';
            content += '<td width="50" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;word-wrap: break-word;"><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;word-wrap: break-word;" class="textarea" data-placement="bottom" data-name="projectprogress"  id="'+field.id+'">'+field.projectprogress+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;word-wrap: break-word;" class="textarea" data-placement="bottom" data-name="gathernote" id="'+field.id+'">'+field.gathernote+'</div></td>';
            content += projecterNameTmp;
            if(!isempt(field.no)) {
                content += '<td width="50"><button class="btn btn-danger btn-xs" onclick="del('+field.id+')">删除</button></td>';
            }else{
                content += '<td width="50"><button class="btn btn-primary btn-xs" onclick="unpacking('+field.id+')">拆包</button>' +
                    '<button class="btn btn-danger btn-xs" onclick="del('+field.id+')">删除</button></td>';
            }
            content += '<td width="50" style="display:none">'+field.id+'</td>';
            content += "</tr>";

            if(len == i && companyName == field.companyname && projectNum >0) {
                budgetTotal = eval(budgetTotal);
                budgetTotal = fomatFloat.toZero(budgetTotal);
                content += "<tr>";
                content += "<th></th>";
                content += "<th colspan='6' align='left'>小计</th>";
                content += "<th colspan='19'>"+budgetTotal+"</th>";
                content += "</tr>";
            }
        });
        totalPrice = fomatFloat.toZero(totalPrice);
        content += "<tr>";
        content += "<td></td>";
        content += "<td colspan='6' align='left'>总计</td>";
        content += "<th colspan='19'>"+totalPrice+"</th>";
        content += "</tr>";
        content += "</thead>";
        content += "</table>";
        $('#veiw_{rand}').html(content);

        // 表格和表头对齐方法
        fun_table_width()

        //编辑input类型
        $('.input').editable({
            type: 'text',
            emptytext: "",
            placement:"bottom",
            url: function (params) { var can = this; editCell(params,this)}
        });
        //编辑date类型
        $('.date').editable({
            placement: 'bottom',
            // showbuttons: 'bottom',
            type: 'date',
            format: 'yyyy-mm-dd',
            clear: '清空',
            emptytext: "", 
            viewformat: 'yyyy-mm-dd',
            datepicker: {inputclass: 'RemoveFocus datepicker-Date', language: 'zh-CN',},
            url: function (params) { var can = this; editCell(params,this)}
        });
        //编辑代理机构类型
        $('.select').editable({
            type: 'select',
            emptytext: "", 
            placement: 'bottom',
            source: getsource(),
            url: function (params) { var can = this; editCell(params,this)}
        });
        //编辑是否签订合同
        $('.select1').editable({
            type: 'select',
            placement: 'bottom',
            emptytext: "",
            value: 2, 
            source: [
                {value: '是', text: '是'},
                {value: '否', text: '否'}
            ],
            url: function (params) { var can = this; editCell(params,this)}
        });
        // //编辑textarea类型
        $('.textarea').editable({
            placement: 'bottom',
            type: 'textarea',
            emptytext: "",
            rows: 10, 
            url: function (params) { var can = this; editCell(params,this)}
        });
    }});
    }
    // 获取代理机构
    function getsource() {
        var result = [];
        $.ajax({
            url: "./index.php?a=getDljgs&m=index&d=cg&ajaxbool=true",
            success: function(obj){
                obj = JSON.parse(obj);
                data = obj;
                $.each(data, function (key, value) {
                    result.push({ value: value.name, text: value.name });
                });
            }
        });
        return result;
    }
    //修改单元格公用方法
    function editCell(params, can) {
        //获取项目id
        parentNode = $(can).parent();
        pid = $(can).attr("id");
        //pid = parentNode.children("td:last").text();
        //获取修改后的值
        var newvalue = params.value;
        var fieldname = params.name;
        //编辑后保存
        $.ajax({
            type: 'POST',
            url: js.getajaxurl('editProjectSummary','{mode}','{dir}'),
            data: {'id':pid, 'value':newvalue, 'fieldname':fieldname},
            success: function (obj) {
                js.msg('success','保存成功');
            }
        });
    }
    //拆包
    function unpacking(id){
        if (isempt(id)){
            js.msg('error','请选中项目');
            return;
        }
        js.ajax(js.getajaxurl('unpacking','{mode}','{dir}'),{id:id},function(s){},'get,json',false,'');
        summaryListsadmin();
    }
    //删除
    function del(id) {
        layer.confirm('是否要删除此项目？', {
            btn: ['是','否'] //按钮
        }, function(){
            js.ajax(js.getajaxurl('delProjectSummary','{mode}','{dir}'),{id:id},function(s){
                if(s.code == 200) {
                    layer.msg('删除成功');
                    summaryListsadmin();
                }else{
                    layer.msg('删除失败');
                }
            },'post,json',false,'');
        });
    }
    var c = {
        search:function(){
            var s=$('#name_{rand}').val();
            var type = $("#type_{rand}").val();
            var sdate=$('#search_sdate_{rand}').val();
            var edate=$('#search_edate_{rand}').val();
            var ksdate=$('#search_ksdate_{rand}').val();
            var kedate=$('#search_kedate_{rand}').val();
            var stbudget=$('#stbudget_{rand}').val();
            var enbudget=$('#enbudget_{rand}').val();
            var bugtype=$('#bugtype_{rand}').val();
            var comid=$('#unit_{rand}').val();
            var projectadminer=$('#projectadminer_{rand}').val();
            summaryListsadmin({name:s,sdate:sdate,edate:edate, type:type, ksdate:ksdate, kedate:kedate,comid:comid, projectadminer:projectadminer,bugtype:bugtype,stbudget:stbudget,enbudget:enbudget},true);
        }
    };
    $(document).ready(function(){
        {params};
        summaryListsadmin(params);
        js.initbtn(c);
    });
</script>
<div>
<style>.bordernone td{border: none!important;}</style>
<table class="table table-condensed bordernone">
    <tr>
        <td width="100">
            <input class="inputs" id="name_{rand}" placeholder="项目名称" />
        </td>
        <td width="100">
            <select class="inputs" id="type_{rand}">
                <option value="">采购类别</option>
                <option value="货物类">货物类</option>
                <option value="服务类">服务类</option>
                <option value="工程类">工程类</option>
                <option value="电子卖场">电子卖场</option>
            </select>
        </td>
        <td width="100">
            <select class="inputs" id="projectadminer_{rand}">
            </select>
        </td>
        <td nowrap width="100">
            <select id="unit_{rand}" class="inputs" >
                <option value="">二级单位</option>
            </select>
        </td>
        <td>
            项目时间
            <input onclick="js.datechange(this,'date')" value="" class="inputs datesss" inputtype="date" readonly="" name="search_sdate" id="search_sdate_{rand}" style="width:100px;">
            <input onclick="js.datechange(this,'date')" value="" class="inputs datesss" inputtype="date" readonly="" name="search_edate" id="search_edate_{rand}" style="width:100px;">
        </td>
        <td width="150">
            <div class="btn-group">
                <button class="btn btn-default" id="t_year_{rand}" type="button" style="height:30px;line-height:1;">年</button>
                <button class="btn btn-default" id="t_season_{rand}" type="button" style="height:30px;line-height:1;">季</button>
                <button class="btn btn-default" id="t_month_{rand}" type="button" style="height:30px;line-height:1;">月</button>
            </div>
        </td>
        <td>
            开标时间
            <input onclick="js.datechange(this,'date')" value="" class="inputs datesss" inputtype="date" readonly="" name="search_ksdate" id="search_ksdate_{rand}" style="width:100px;">
            <input onclick="js.datechange(this,'date')" value="" class="inputs datesss" inputtype="date" readonly="" name="search_kedate" id="search_kedate_{rand}" style="width:100px;">
        </td>
        <td nowrap>
            <button class="btn btn-primary" click="search" type="button" style="height:30px;line-height:1;">检索</button>
            <button class="btn btn-primary" id="downExce_{rand}" type="button" style="height:30px;line-height:1;">下载汇总表</button>
            <button class="btn btn-primary" id="downExceJHB_{rand}" type="button" style="height:30px;line-height:1;">下载计划表</button>
        </td>
        <td width="10%"></td>
    </tr>
    <tr>
<!--        <td><button class="btn btn-primary" click="unpacking" style="width:89px;height:30px;line-height:1;">拆包</button></td>-->
    </tr>
</table>
</div>
<div style="min-width:2800px;">
    <table id="table_h" class='table table-bordered table-hover' style='position:relative;table-layout: fixed;word-break:break-all; word-wrap:break-all;margin-bottom:0 !important;width:99.4%; '>
        <thead>
            <tr style=''>
                <th width='25'>序号</th>
                <th width='50'>单位</th>
                <th width='50'>项目名称<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>批准书文号<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>批准书获得时间<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>采购类别</th>
                <th width='50'>采购方式</th>
                <th width='75'>预算金额<i class='glyphicon glyphicon-edit'></i></th>
                <th width='75'>审减后金额<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>中标金额<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>节约金额(预算节约)<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>节约金额(审减节约)<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>节约率(预算)<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>节约率(审减)<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>代理机构<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>报名单位情况<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>公告时间<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>开标时间<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>完标时间<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>中标单位<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>合同是否签订<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>档案整理情况<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>项目进展情况<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>备注<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>项目负责人</th>
                <th width='50'>操作</th>
            </tr>
        </thead>
    </table>
    <div class="table-box" style='height:750px;overflow-y:auto;'>
    <!-- <div class="blank10"></div> -->
    <div id="veiw_{rand}"></div>
    <div id="page_{rand}"></div>
    </div>
</div>
<script>
    var date=new Date;
    var y = date.getFullYear()
    $('#search_sdate_{rand}').val(y+'-01-01');

    $(document).ready(function(){
        function loadProjectadminer(){
            js.ajax(js.getajaxurl('loadProjectadminner','index','cg'),
                {
                },function(s){
                    var ccc ="<option value=''>--项目负责人--</option>";
                    $.each(s, function(i, field){
                        ccc += "<option value='"+field.id+"'>"+field.name+"</option>";
                    });
                    $("#projectadminer_{rand}").html(ccc);
                },'get,json',false,'');
            $.ajax({ url: "./index.php?a=getCompanyList&m=main&d=report&ajaxbool=true", success: function(obj){
                var ccc ="<option value=''>二级单位</option>";
                obj = JSON.parse(obj);
                data = obj.rows;
                for(i=0;i<data.length;i++){
                    ccc += "<option value='"+data[i].id+"'>"+data[i].name+"</option>";
                };
                $('#unit_{rand}').html(ccc);
            }});
        }
        loadProjectadminer();
    });
    //下載文件
    $(document).ready(function(){
        $("#downExce_{rand}").click(function(){
            var name = $('input[id^="name_'+'"]').val();
            var type = $('select[id^="type_'+'"]').val();
            var projectadminer = $('select[id^="projectadminer_'+'"]').val();
            var sdate = $('input[id^="search_sdate_'+'"]').val();
            var edate = $('input[id^="search_edate_'+'"]').val();
            var ksdate = $('input[id^="search_ksdate_'+'"]').val();
            var kedate = $('input[id^="search_kedate_'+'"]').val();
            var comid=$('#unit_{rand}').val();
            top.location='./index.php?a=zbqkhzb&m=office|index&d=cg&ajaxbool=true&projectadminer='+projectadminer+'&utype='+1+'&name='+name+'&type='+type+'&sdate='+sdate+'&edate='+edate+'&ksdate='+ksdate+'&kedate='+kedate+'&comid='+comid;
        });
        $("#downExceJHB_{rand}").click(function(){
            var name = $('input[id^="name_'+'"]').val();
            var type = $('select[id^="type_'+'"]').val();
            var projectadminer = $('select[id^="projectadminer_'+'"]').val();
            var sdate = $('input[id^="search_sdate_'+'"]').val();
            var edate = $('input[id^="search_edate_'+'"]').val();
            var ksdate = $('input[id^="search_ksdate_'+'"]').val();
            var kedate = $('input[id^="search_kedate_'+'"]').val();
            var comid=$('#unit_{rand}').val();
            window.open('./index.php?a=cgzbjhb&m=office|index&d=cg&ajaxbool=true&projectadminer='+projectadminer+'&utype='+1+'&name='+name+'&type='+type+'&sdate='+sdate+'&edate='+edate+'&ksdate='+ksdate+'&kedate='+kedate+'&comid='+comid);
        });
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth();
        var month = month + 1;
        if(month.toString().length == 1) {
            month = '0' + month;
        }
        var day = date.getDate();
        $("#t_year_{rand}").click(function(){
            var sdate=$('#search_sdate_{rand}').val(year+'-01-01');
            var edate=$('#search_edate_{rand}').val(year+'-12-31');
        });
        $("#t_season_{rand}").click(function(){
            stime = '';
            etime = '';
            switch(true) {
                case (month <= 3):
                    stime = year+'-01-01';
                    etime = year+'-03-31';
                    break;
                case (3 < month <= 6):
                    stime = year+'-04-01';
                    etime = year+'-06-30';
                    break;
                case (6 < month <= 9):
                    stime = year+'-07-01';
                    etime = year+'-09-30';
                    break;
                case (9 < month <= 12):
                    stime = year+'-10-01';
                    etime = year+'-12-31';
                    break;
            }
            var sdate=$('#search_sdate_{rand}').val(stime);
            var edate=$('#search_edate_{rand}').val(etime);
        });
        $("#t_month_{rand}").click(function(){
            var lastDay= new Date(year,month,0).getDate();
            var sdate=$('#search_sdate_{rand}').val(year+'-'+month+'-01');
            var edate=$('#search_edate_{rand}').val(year+'-'+month+'-'+lastDay);
        });
    });
</script>